package com.ruoyi.zhike.controller.account;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import com.ruoyi.common.security.annotation.RequiresPermissions;
import com.ruoyi.zhike.db.domain.AccountMerchantInfoHis;
import com.ruoyi.zhike.account.service.IAccountMerchantInfoHisService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.utils.poi.ExcelUtil;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.zhike.wrapper.AccountMerchantInfoHisWrapper;

/**
 * 商户账户流水Controller
 * 
 * @author ruoyi
 * @date 2024-04-19
 */
@RestController
@RequestMapping("/account/merAccountInfoHis")
public class AccountMerchantInfoHisController extends BaseController
{
    @Autowired
    private IAccountMerchantInfoHisService accountMerchantInfoHisService;

    /**
    *
    */
    @GetMapping("/extData")
    public AjaxResult extData() {
        JSONObject returnData = new JSONObject();

        return AjaxResult.success(returnData);
    }

    /**
     * 查询商户账户流水列表
     */
    @RequiresPermissions("account:merAccountInfoHis:list")
    @GetMapping("/list")
    public TableDataInfo list(AccountMerchantInfoHis accountMerchantInfoHis)
    {
        startPage();
        List<Map<String, Object>> list = accountMerchantInfoHisService.selectAccountMerchantInfoHisListMap(accountMerchantInfoHis);
        list = new AccountMerchantInfoHisWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出商户账户流水列表
     */
    @RequiresPermissions("account:merAccountInfoHis:export")
    @Log(title = "商户账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountMerchantInfoHis accountMerchantInfoHis)
    {
        List<AccountMerchantInfoHis> list = accountMerchantInfoHisService.selectAccountMerchantInfoHisList(accountMerchantInfoHis);
        ExcelUtil<AccountMerchantInfoHis> util = new ExcelUtil<AccountMerchantInfoHis>(AccountMerchantInfoHis.class);
        util.exportExcel(response, list, "商户账户流水数据");
    }

    /**
     * 获取商户账户流水详细信息
     */
    @RequiresPermissions("account:merAccountInfoHis:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountMerchantInfoHisService.selectAccountMerchantInfoHisById(id));
    }

    /**
     * 新增商户账户流水
     */
    @RequiresPermissions("account:merAccountInfoHis:add")
    @Log(title = "商户账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountMerchantInfoHis accountMerchantInfoHis)
    {
        return toAjax(accountMerchantInfoHisService.insertAccountMerchantInfoHis(accountMerchantInfoHis));
    }

    /**
     * 修改商户账户流水
     */
    @RequiresPermissions("account:merAccountInfoHis:edit")
    @Log(title = "商户账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountMerchantInfoHis accountMerchantInfoHis)
    {
        return toAjax(accountMerchantInfoHisService.updateAccountMerchantInfoHis(accountMerchantInfoHis));
    }

    /**
     * 删除商户账户流水
     */
    @RequiresPermissions("account:merAccountInfoHis:remove")
    @Log(title = "商户账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountMerchantInfoHisService.deleteAccountMerchantInfoHisByIds(ids));
    }
}
